const fs = window.require('fs').promises
// const path = window.require('path')
class fsHelper {
  static readFile(path) {
    return fs.readFile(path, { encoding: 'utf8' })
  }

  static writeFile(path, content) {
    return fs.writeFile(path, content, { encoding: 'utf8' })
  }

  static reanmeFile(path, renamePath) {
    return fs.rename(path, renamePath);
  }
  static deleteFile(path) {
    return fs.unlink(path);
  }
}

export default fsHelper

// const testReadPath = path.resolve(__dirname, 'helper.js');

// fsHelper.readFile(testReadPath).then(data => {
//   console.log(data)
// }).catch(err => {
//   console.log('err')
// })

// const testWritePath = path.join(__dirname, 'hello2.md');
// fsHelper.writeFile(testWritePath,'### hello world2').then(res => {
//   console.log('写入成功')
// }).catch(err=> {
//   console.log('err',err);
// })

// const renamePath = path.join(__dirname, 'helloWorld.md');

// fsHelper.reanmeFile(testWritePath,renamePath).then(() => {
//   console.log('重命名成功')
// }).catch(err=> {
//    console.log('重命名失败')
// });

// fsHelper.deleteFile(renamePath).then(() => {
//   console.log('删除成功')
// }).catch(err => {
//   console.log('err',err);
// })